import uuid

class MessageEnrichUtils:
    @staticmethod
    def generate():
        """
        Generate a random UUID string
        Returns:
            str: A string representation of UUID4
        """
        return str(uuid.uuid4())

    @staticmethod
    def generate_short():
        """
        Generate a shorter random UUID string (first 8 characters)
        Returns:
            str: First 8 characters of a UUID4 string
        """
        return str(uuid.uuid4())[:8]

    @staticmethod
    def enrich_uniq_message(message: dict):
        """
        Generate a shorter random UUID string (first 8 characters)
        Returns:
            str: First 8 characters of a UUID4 string
        """
        uniq_id = MessageEnrichUtils.generate()
        message['uniq_id'] = uniq_id
        return uniq_id, message
    
    @staticmethod
    def enrich_response(message: dict, response: any):
        """
        """
        message['response'] = response
        return message

    @staticmethod
    def enrich_handler(message: dict, handler: str):
        """
        """
        message['handler'] = handler
        return message
    
    @staticmethod
    def enrich_related_questiones(message: dict, questiones: list):
        """
        """
        all_questiones = [f"{i+1}.{q}" for i, q in enumerate(questiones)]
        all_questiones_str = '\n'.join(all_questiones)
        message['response'] = f"含义类似的问题：\n{all_questiones_str}" 
        return message
    
    @staticmethod
    def enrich_related_chunks(message: dict, chunks: list):
        """
        """
        all_chunks = [f"文本片段{i+1}：{q}" for i, q in enumerate(chunks)]
        all_chunks_str = '\n==================================================\n'.join(all_chunks)
        message['response'] = f"相关文本块：\n {all_chunks_str}" 
        return message